using System.IO;
using System.Web.Mvc;

namespace iArtis.Models.Localization
{
    public class LocalizationWebFormView : WebFormView
    {
        internal const string ViewPathKey = "__ViewPath__";

        public LocalizationWebFormView(string viewPath) : base(viewPath)
        {
        }

        public LocalizationWebFormView(string viewPath, string masterPath) : base(viewPath, masterPath)
        {
        }

        public override void Render(ViewContext viewContext, TextWriter writer)
        {
            var originalViewPath = (string) viewContext.ViewData[ViewPathKey];

            viewContext.ViewData[ViewPathKey] = ViewPath;
            base.Render(viewContext, writer);

            viewContext.ViewData[ViewPathKey] = originalViewPath;
        }
    }
}